package collection.list;

import java.util.Stack;

import org.junit.Test;

/**
 * Stack继承至Vector,底层是数组实现,几乎全部用的是Vector的方式,栈后进先出
 * Vector的实现和ArrayList几乎一样,不同的是add和get方法全部加了synchronized锁
 * @author jiangwz
 * @create 2019/9/29.
 */
public class TestStack {

    @Test
    public void testStack(){
        Stack<Integer> stack = new Stack<>();
        stack.push(1);
        stack.push(2);
        stack.push(3);

        System.out.println(stack.peek()); //3
        System.out.println(stack.pop());//3
        System.out.println(stack.pop());//2

    }
}
